#include <stdio.h>

int check(int n,int* a) {
    for (int i = 0; i < n; i++) {
        int cur = a[i];
        for (int j = i + 1; j < n; j++) {
            if (a[j] > a[i]) continue;
            if (a[j] > cur) return 0;
            cur = a[j];
        }
    }
    return 1;
}
int main() {
    int n;
    while(scanf("%d",&n)!= EOF) {
        if(n==0) return 0;
        int arr[101];
        for(int i=0;i<n;i++){
            scanf("%d",&arr[i]);
        }
        if(check(n,arr)) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}